package com.tct.ndocgen.config;

import com.tct.ndocgen.entity.Rs;
import com.tct.ndocgen.entity.enums.RsEnum;
import com.tct.ndocgen.util.RsUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


/**
 * 自定义全局异常处理
 **/
@RestControllerAdvice
@Slf4j
public class CustomExceptionHandler {

    @ExceptionHandler
    public Rs exceptionHandler(Exception e){
        e.printStackTrace();
        log.error("Error Message:{}",e.getMessage());
        return RsUtil.error(RsEnum.SYSTEM_ERROR,e.getMessage());
    }
}
